const path = require('path');

module.exports = (env, argv) => ({
  entry: {
    'config/config': './src/config/config.js',
    'desktop/desktop': './src/desktop/desktop.js',
  },
  output: {
    filename: '[name].min.js',
    path: path.resolve(__dirname, 'src')
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        include: [
          path.resolve(__dirname, 'node_modules/@kintone/kintone-ui-component/esm/js'),
          path.resolve(__dirname, 'src')
        ],
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              [
                '@babel/preset-env',
              ]
            ],
            plugins: [
              '@babel/plugin-transform-object-assign',
            ]
          }
        }
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
      }
    ]
  },
  devtool: argv.mode === 'development' ? 'inline-cheap-source-map' : false,
});